package apcsif;  

  


/**
 * Write a description of class Player here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
import java.util.Arrays;
import java.util.Scanner;

public class Player {
	private static String name;
	private boolean gender;
	private String[] inv;
	public static String[] hand;
	static Scanner scan = new Scanner(System.in);

	public Player(String pName, boolean mf) {
		name = pName;
		gender = mf;
		inv = new String[20];
		hand = new String[2];

		for (int c = 0; c <= 19; c++) {
			inv[c] = "[empty]";
		}
		hand[0] = "nothing";
		hand[1] = "nothing";
	}
	
	public String getHands(){
		return(hand[0] + hand [1]);
	}

	public void getInv() {
		int place = 0;
		for (int r = 0; r < 4; r++) {
			for (int c = 0; c < 5; c++) {
				System.out.print(inv[place] + "\t");

				place++;
			}
			System.out.println();
		}
	}

	public void equip(String item) {
		System.out.println("-- " + item);
		if(item.length()<=0){
			System.out.println("What do you want to equip?");
		}
		else{
		int place;
		String transfer;
		Scanner scan = new Scanner(System.in);
		String lr;

		System.out.println("Which hand?");
		lr = scan.nextLine();
		Arrays.sort(inv);
		place = Arrays.binarySearch(inv, item);
		transfer = inv[place];
		switch (lr) {
		case "left":
		case "l":
			inv[place] = hand[0];
			hand[0] = transfer;
			System.out.println("You equiped the " + item);
			break;
		case "right":
		case "r":
			inv[place] = hand[1];
			hand[1] = transfer;
			System.out.println("You equiped the " + item);
			break;
		default:
			System.out.println("Thats not a hand");
			break;
		}
		}
	}

	public void add(String item) {

		for (int c = 0; c <= 19; c++) {
			if (inv[c] == "[empty]") {
				inv[c] = item;
				System.out.println(item + " has been added to your inventory");
				//Parser.setParam("");
				return;
			}
		}

		System.out.println("You dont have any space");
	}

	public void discard(String item) {
		Arrays.sort(inv);
		inv[Arrays.binarySearch(inv, item)] = "[empty]";
		System.out.println("You lost a " + item);
		//Parser.setParam("");
	}

	public void suicide() {
		// if location == roof
		// {
		System.out.println("You run and jump off the roof, attempting to fly");
		gameOver();
		// else{
		System.out.println("You don't have a high enough place to jump from");
		// }
	}

	public static void gameOver() {
		System.out.println("You hit the ground and the world goes black. A hook "
						+ "handed man apperates,\ncloaked in darkness.");
	    Sys.sp("Hook Handed Man: Ya sane Marethyu."
						+ "\n\"I am Death.\"\n\nI welcome you.\n\n");
		Sys.delay(3);
		Sys.sp("Game Over");
		Sys.delay(5);
		credits();
		System.exit(0);
	}
	public static String getLeft()
	{
		return hand[0];
	}
	public static String getRight()
	{
		return hand[1];
	}
	public static String getName()
	{
		return name;
	}
	public static void credits()
	{
		Sys.sp("World design       Josh");
		Sys.delay(2);
		Sys.sp("Parser             Andrew");
		Sys.delay(2);
		Sys.sp("Storyline          Loki");
		Sys.delay(2);
		Sys.sp("Battle design      Randrew Roover");
		Sys.delay(2);
		Sys.sp("Mob design         Mojang");
		Sys.delay(2);
		Sys.sp("Title              Snow White");
		Sys.delay(2);
		Sys.sp("Player             " + Globals.name());
		Sys.delay(2);
		Sys.sp("Time Extension     Mr. Echols");
		Sys.delay(2);
		Sys.sp("Sacrifice          TMAC");
		Sys.delay(2);
		Sys.sp("Attempted Failure  The Fourth Age");
		Sys.delay(2);
		Sys.sp("Credits Reader     "+ Globals.name());
		Sys.delay(2);
		Sys.sp("Thanks for Playing! -Josh and Andrew");
		Sys.delay(2);
	}
	public static void win()
	{
	    System.out.println("You walk over to your computer and place the mirror in front of the monitor. You take your");
	    System.out.println("cables and rewire the computer to run in reverse. You run On_The_Wall_Runner.java");
	    System.out.println("and the world goes black");
	    scan.nextLine();
	    System.out.println("When you come to, Mr. Echols is teaching the class as the kids in the back row");
	    System.out.println("work on their projects. The world looks normal. You look at your screen and credits are rolling on it");
	    credits();
	    System.exit(0);
	   }
}
